package 优先算法.位运算.丢失的数字;

/**
 * https://leetcode.cn/problems/missing-number/description/
 */
public class Main {
    public static void main(String[] args) {
        Solution so = new Solution();
        int[] arr = {9,6,4,2,3,5,7,0,1};
        int rel = so.missingNumber(arr);

        System.out.println(rel);
    }
}
class Solution {
    public int missingNumber(int[] nums) {
        int rel = 0,n = nums.length;

        for (int i = 0; i < n;i++){
            rel ^= i^nums[i];
        }
        return rel^n;
    }
}